package com.zmx.patientend.adapter;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.wang.adapters.adapter.BaseAdapterRvList;
import com.wang.adapters.base.BaseViewHolder;
import com.zmx.patientend.R;
import com.zmx.patientend.pojo.BraceletData;

import butterknife.BindView;
import butterknife.ButterKnife;

public class BraceletDataAdapter  extends BaseAdapterRvList<BraceletDataAdapter.ViewHolder, BraceletData> {

    private int state = 0;

    public BraceletDataAdapter(Activity activity,int state) {
        super(activity);
        this.state = state;
    }

    public BraceletDataAdapter(Activity activity) {
        super(activity);
    }

    @Override
    protected void onBindVH(ViewHolder holder, int listPosition, BraceletData braceletData) {

        holder.bp.setText(braceletData.getBp()+"/120");
        holder.name.setText(braceletData.getName());
        holder.bt.setText(braceletData.getBt());
        holder.hr.setText(braceletData.getHr());

        if (state == 0){


            holder.tiwen.setText("当前体温"+braceletData.getBt()+"，正常范围36℃-37℃");
            holder.xueya.setText("当前血压"+braceletData.getBp()+"，正常范围90~139mmHg");

        }else{

            holder.tiwen.setVisibility(View.GONE);
            holder.xueya.setVisibility(View.GONE);
        }


    }

    @NonNull
    @Override
    protected ViewHolder onCreateVH(ViewGroup parent, LayoutInflater inflater) {

        BraceletDataAdapter.ViewHolder holder = new BraceletDataAdapter.ViewHolder(inflater.inflate(R.layout.adapter_bracelet_data, parent, false));
        return holder;

    }

    static class ViewHolder extends BaseViewHolder {

        @BindView(R.id.bp)
        TextView bp;
        @BindView(R.id.bt)
        TextView bt;
        @BindView(R.id.hr)
        TextView hr;
        @BindView(R.id.tiwen)
        TextView tiwen;
        @BindView(R.id.xueya)
        TextView xueya;
        @BindView(R.id.name)
        TextView name;

        ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }

    }

}
